#!/bin/bash
if [ "$1" == "" ];then
	exit -1;
fi
index=0
if [ -f "index" ];then
	index=`cat index`
fi
let index=$index+1
if [ $index -gt 5 ];then
	index=1
fi
echo $index > index
sed -n "${index},${index}p" getIp>_command
ip=`sh _command|grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"`
write=1
if [[ ${ip} != "" ]];then
	if [ -f $1 ];then
		if [ `cat $1` != ${ip} ] ;then
			write=0
		fi
	else
		git add $1
		write=0
	fi
	if [ ${write} -eq 0 ];then
		echo ${ip}>$1
	fi
fi
rm -f _command